<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // const arr = [1, 2]
        // // const arr2 = arr;
        // const arr2 = [...arr];
        // arr2[0] = 999
        // console.log(arr2[0])
        // console.log(arr[0])

        // 因为里面嵌套还有一层对象，所以浅拷贝
        const arr = [{ a: 1 }]
        const arr2 = [...arr];
        arr2[0].a = 999
        console.log(arr2[0].a)
        console.log(arr[0].a)
    </script>
</body>

</html>